package controller

import (
	"strconv"

	"device-admin/internal/dal"
	"device-admin/internal/dao"

	"192.168.1.75/go-pkg/response"
	"github.com/gin-gonic/gin"
)

type HeatMap struct{}

// List 获取热力图数据
func (HeatMap) List(c *gin.Context) {
	startTime, _ := strconv.ParseInt(c.Query("start_time"), 10, 64)
	endTime, _ := strconv.ParseInt(c.Query("end_time"), 10, 64)
	data, _ := dao.Heatmap{}.PositionData(c.Request.Context(), dal.Q, c.Query("robot_id"), c.Query("map_id"), startTime, endTime)
	response.JSON(c, map[string]interface{}{
		"list":  data,
		"total": len(data),
	}, nil)
}

// MapList 热力图的地图列表
func (HeatMap) MapList(c *gin.Context) {
	startTime, _ := strconv.ParseInt(c.Query("start_time"), 10, 64)
	endTime, _ := strconv.ParseInt(c.Query("end_time"), 10, 64)
	mapList, _ := dao.Heatmap{}.MapList(c.Request.Context(), dal.Q, c.Query("robot_id"), startTime, endTime)
	response.JSON(c, map[string]interface{}{
		"list":  mapList,
		"total": len(mapList),
	}, nil)
}
